﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HelpNetwork
{   
    public partial class ConfigurareSenzori : Form
    {
        //Parametrii myParam;
        private delegate void UpdateAutoParameterCallback(ref Parametrii myParam);

          
        public ConfigurareSenzori()
        {
            InitializeComponent();
        }

        public void makeAutoParameters()
        {
            UpdateAutoParameterCallback cb = new UpdateAutoParameterCallback(Principal.configSenzoriInstance.updateParametrii);
            Principal.mainForm.Invoke(cb, new object[] { Principal.mainForm.appParam });
        }

        private void ConfigurareSenzori_Load(object sender, EventArgs e)
        {
            this.Focus();
            this.Height = 156; this.Width = 404;
            lbFrecventaRespiratorie2.Visible = false; txtFrecventaRespiratoriedata.Visible = false;
            lbGaz2.Visible = false; cbxGaz.Visible = false;
            lbGlicemie2.Visible = false; txtGlicemiedata.Visible = false;
            lbGreutate2.Visible = false; txtGreutatedata.Visible = false;
            lbHTA2.Visible = false; txtDiastolica.Visible = false; txtSistolica.Visible = false; lbDiastolica.Visible = false; lbSistolica.Visible = false;
            lbPuls2.Visible = false; txtPulsdata .Visible  = false;
            lbRFID2.Visible = false; cbxRFID.Visible = false;
            lbTensiuneRetea2.Visible = false; cbxTensiune.Visible = false;
            lbUmiditate2.Visible = false; cbxUmiditate.Visible = false;
            btSalvareParam.Visible = false; btSalvare.Visible = false; gbxConfig.Visible = false;

            cbxLimitaSup.Visible = false;
            cbxLimitaInf.Visible = false;
            cbxAlarma.Visible = false;
            

            initParametrii();
         }

        private void btManuala_Click(object sender, EventArgs e)
        {
            Principal.seGenereazaAutomat = false;
            this.Height = 466; this.Width = 746;
            gbxConfig.Visible = true;
            nupLimitainf.Visible = false;
            nupLimitasup.Visible = false;
            lbLimitaInf.Visible = false;
            lbLImitaSup.Visible = false;
            lbFrecventaRespiratorie2.Visible = true; txtFrecventaRespiratoriedata.Visible = true; txtFrecventaRespiratoriedata.ReadOnly = false ;
            lbGaz2.Visible = true; cbxGaz.Visible = true; cbxGaz.Enabled = true;
            lbGlicemie2.Visible = true; txtGlicemiedata.Visible = true; txtGlicemiedata.ReadOnly = false ;
            lbGreutate2.Visible = true; txtGreutatedata.Visible = true; txtGreutatedata.ReadOnly = false ;
            lbHTA2.Visible = true; txtDiastolica.Visible = true; txtDiastolica.ReadOnly = false; txtSistolica.Visible = true ; lbDiastolica.Visible = true ; lbSistolica.Visible =  true ; txtSistolica.ReadOnly = false;
            lbPuls2.Visible = true; txtPulsdata.Visible = true; txtPulsdata.ReadOnly = false ;
            lbRFID2.Visible = true; cbxRFID.Visible = true; cbxRFID.Enabled = true;
            lbTensiuneRetea2.Visible = true; cbxTensiune.Visible = true; cbxTensiune.Enabled  = true ;
            lbUmiditate2.Visible = true; cbxUmiditate.Visible = true; cbxUmiditate.Enabled = true;
            btSalvareParam.Visible = true ; btSalvare.Visible =  true ;
            btManuala.Visible = false; btAutomata.Visible = false;
            cbxLimitaInf.Visible = false;
            cbxLimitaSup.Visible = false;
            nupLimitainf.Visible = false;
            nupLimitasup.Visible = false;

            cbxConfigurare.SelectedIndex = 0;
            txtDiastolica.Text = Principal.mainForm.appParam.parametriiCurenti.HTA.Diastolic.ToString();
            txtFrecventaRespiratoriedata.Text = Principal.mainForm.appParam.parametriiCurenti.frecvResp.ToString();
            txtGlicemiedata.Text = Principal.mainForm.appParam.parametriiCurenti.glicemie.ToString();
            txtGreutatedata.Text = Principal.mainForm.appParam.parametriiCurenti.greutate.ToString();
            txtPulsdata.Text = Principal.mainForm.appParam.parametriiCurenti.puls.ToString();
            txtSistolica.Text = Principal.mainForm.appParam.parametriiCurenti.HTA.Sistolic.ToString();
            cbxUmiditate.SelectedIndex = 0;
            cbxTensiune.SelectedIndex = 0;
            cbxRFID.SelectedIndex = 0;
            cbxGaz.SelectedIndex = 0;

        }

        private void btAutomata_Click(object sender, EventArgs e)
        {
            Principal.seGenereazaAutomat = true;
            this.Height = 466; this.Width = 746;
            gbxConfig.Visible = true;
            nupLimitainf.Visible = true ;
            nupLimitasup.Visible = true ;
            lbLimitaInf.Visible = true  ;
            lbLImitaSup.Visible = true ;
            lbFrecventaRespiratorie2.Visible = true; txtFrecventaRespiratoriedata.Visible = true; txtFrecventaRespiratoriedata.ReadOnly = true ;
            lbGaz2.Visible = true; cbxGaz.Visible = true; cbxGaz.Enabled  = false ;
            lbGlicemie2.Visible = true; txtGlicemiedata.Visible = true; txtGlicemiedata.ReadOnly = true ;
            lbGreutate2.Visible = true; txtGreutatedata.Visible = true; txtGreutatedata.ReadOnly = true ;
            lbHTA2.Visible = true; txtDiastolica.Visible = true; txtDiastolica.ReadOnly = true; txtSistolica.Visible = true; lbDiastolica.Visible = true; lbSistolica.Visible = true; txtSistolica.ReadOnly = true ;
            lbPuls2.Visible = true; txtPulsdata.Visible = true; txtPulsdata.ReadOnly = true ;
            lbRFID2.Visible = true; cbxRFID.Visible = true; cbxRFID.Enabled = false;
            lbTensiuneRetea2.Visible = true; cbxTensiune.Visible = true; cbxTensiune.Enabled = false;
            lbUmiditate2.Visible = true; cbxUmiditate.Visible = true; cbxUmiditate.Enabled = false;
            btSalvareParam.Visible = true ; btSalvare.Visible = true;
            btAutomata.Visible = false; btManuala.Visible = false;
        }
        
        private static void ThreadProc()
        {
            Application.Run(new Principal ());
            
        }
        private void btSalvare_Click(object sender, EventArgs e)
        {
            makeAutoParameters();
            salvareParametrii();
           
           this.Close();
        }
        public void salvareParametrii()
        {
                Principal.mainForm.appParam.parametriiCurenti.frecvResp = UInt16.Parse(txtFrecventaRespiratoriedata.Text);
                Principal.mainForm.appParam.parametriiCurenti.HTA.Diastolic = UInt16.Parse(txtDiastolica.Text);
                Principal.mainForm.appParam.parametriiCurenti.HTA.Sistolic = UInt16.Parse(txtSistolica.Text);
                Principal.mainForm.appParam.parametriiCurenti.puls = UInt16.Parse(txtPulsdata.Text);
                Principal.mainForm.appParam.parametriiCurenti.greutate = UInt16.Parse(txtGreutatedata.Text);
                Principal.mainForm.appParam.parametriiCurenti.glicemie = UInt16.Parse(txtGlicemiedata.Text);

                if (cbxGaz.SelectedIndex == 1)
                    Principal.mainForm.appParam.parametriiCurenti.gaz = false;
                else
                    Principal.mainForm.appParam.parametriiCurenti.gaz = true;

                if (cbxUmiditate.SelectedIndex == 1)
                    Principal.mainForm.appParam.parametriiCurenti.umiditate = false;
                else
                    Principal.mainForm.appParam.parametriiCurenti.umiditate = true;

                if (cbxRFID.SelectedIndex == 1)
                    Principal.mainForm.appParam.parametriiCurenti.RFID = false;
                else
                    Principal.mainForm.appParam.parametriiCurenti.RFID = true;

                if (cbxTensiune.SelectedIndex == 1)
                    Principal.mainForm.appParam.parametriiCurenti.tensiuneRetea = false;
                else
                    Principal.mainForm.appParam.parametriiCurenti.tensiuneRetea = true;


            
        }
        private void btSalvareParam_Click(object sender, EventArgs e)
        {
            switch (cbxConfigurare.SelectedIndex)
            {
                case 0://"HTA":
                    Principal.mainForm.appParam.HTA.limitaInf = (int)nupLimitainf.Value;
                    if (nupLimitainf.Visible == true && nupLimitasup.Visible == true)
                    {
                        Principal.mainForm.appParam.HTA.limitaSup = (int)nupLimitasup.Value;
                        Principal.mainForm.appParam.HTA.alarma = (int)nupAlarma.Value;
                    }
                        break;
                case 1://"Puls":
                        Principal.mainForm.appParam.Puls.alarma = (int)nupAlarma.Value;
                    if (nupLimitainf.Visible == true && nupLimitasup.Visible == true)
                    {
                        Principal.mainForm.appParam.Puls.limitaInf = (int)nupLimitainf.Value;
                        Principal.mainForm.appParam.Puls.limitaSup = (int)nupLimitasup.Value;
                    }
                        break;

                case 2://"Greutate":
                        Principal.mainForm.appParam.Greutate.alarma = (int)nupAlarma.Value;
                    if (nupLimitainf.Visible == true && nupLimitasup.Visible == true)
                    {
                        Principal.mainForm.appParam.Greutate.limitaInf = (int)nupLimitainf.Value;
                        Principal.mainForm.appParam.Greutate.limitaSup = (int)nupLimitasup.Value;
                    }
                        break;
                case 3://"Glicemie":
                        Principal.mainForm.appParam.Glicemie.alarma = (int)nupAlarma.Value;
                    if (nupLimitainf.Visible == true && nupLimitasup.Visible == true)
                    {
                        Principal.mainForm.appParam.Glicemie.limitaInf = (int)nupLimitainf.Value;
                        Principal.mainForm.appParam.Glicemie.limitaSup = (int)nupLimitasup.Value;
                    }
                        break;
                case 4:// "FrecventaRespiratorie":
                        Principal.mainForm.appParam.FrecventaRespiratorie.alarma = (int)nupAlarma.Value;
                    if (nupLimitainf.Visible == true && nupLimitasup.Visible == true)
                    {
                        Principal.mainForm.appParam.FrecventaRespiratorie.limitaInf = (int)nupLimitainf.Value;
                        Principal.mainForm.appParam.FrecventaRespiratorie.limitaSup = (int)nupLimitasup.Value;
                    }
                        break;
                case 5://"Gaz":
                        if (cbxAlarma.SelectedIndex == 1)
                            Principal.mainForm.appParam.Gaz.alarma = 0;
                        else
                            Principal.mainForm.appParam.Gaz.alarma = 1;
                        if (cbxLimitaInf.Visible == true && cbxLimitaSup.Visible == true)
                        {
                            if (cbxLimitaInf.SelectedIndex == 1)
                                Principal.mainForm.appParam.Gaz.limitaInf = 0;
                            else
                                Principal.mainForm.appParam.Gaz.limitaInf = 1;
                            if (cbxLimitaSup.SelectedIndex == 1)
                                Principal.mainForm.appParam.Gaz.limitaSup = 0;
                            else
                                Principal.mainForm.appParam.Gaz.limitaSup = 1;
                        }
                        break;
                case 6://"Umiditate":
                        if (cbxAlarma.SelectedIndex == 1)
                            Principal.mainForm.appParam.Umiditate.alarma = 0;
                        else
                            Principal.mainForm.appParam.Umiditate.alarma = 1;
                        if (cbxLimitaInf.Visible == true && cbxLimitaSup.Visible == true)
                        {
                            if (cbxLimitaInf.SelectedIndex == 1)
                                Principal.mainForm.appParam.Umiditate.limitaInf = 0;
                            else
                                Principal.mainForm.appParam.Umiditate.limitaInf = 1;
                            if (cbxLimitaSup.SelectedIndex == 1)
                                Principal.mainForm.appParam.Umiditate.limitaSup = 0;
                            else
                                Principal.mainForm.appParam.Umiditate.limitaSup = 1;
                        }
                        break;
                case 7://"RFID":
                    if (cbxAlarma.SelectedIndex == 1)
                        Principal.mainForm.appParam.RFID.alarma = 0;
                    else
                        Principal.mainForm.appParam.RFID.alarma = 1;
                    if (cbxLimitaInf.Visible == true && cbxLimitaSup.Visible == true)
                    {
                        if (cbxLimitaInf.SelectedIndex == 1)
                            Principal.mainForm.appParam.RFID.limitaInf = 0;
                        else
                            Principal.mainForm.appParam.RFID.limitaInf = 1;
                        if (cbxLimitaSup.SelectedIndex == 1)
                            Principal.mainForm.appParam.RFID.limitaSup = 0;
                        else
                            Principal.mainForm.appParam.RFID.limitaSup = 1;
                    }
                        break;
                case 8://"Tensiune":


                        if (cbxAlarma.SelectedIndex == 1)
                            Principal.mainForm.appParam.Tensiune.alarma = 0;
                        else
                            Principal.mainForm.appParam.Tensiune.alarma = 1;
                        if (cbxLimitaInf.Visible == true && cbxLimitaSup.Visible == true)
                        {
                            if (cbxLimitaInf.SelectedIndex == 1)
                                Principal.mainForm.appParam.Tensiune.limitaInf = 0;
                            else
                                Principal.mainForm.appParam.Tensiune.limitaInf = 1;
                            if (cbxLimitaSup.SelectedIndex == 1)
                                Principal.mainForm.appParam.Tensiune.limitaSup = 0;
                            else
                                Principal.mainForm.appParam.Tensiune.limitaSup = 1;
                        }
                
                        break;
                default:
                    MessageBox.Show("Trebuie sa selectati un senzor pentru configurare parametrii ","Eroare de configurare");
                    break;
            }
        }

        private void ConfigurareSenzori_FormClosed(object sender, FormClosedEventArgs e)
        {
            Principal.mainForm.Enabled = true;
        }
        private void initParametrii()
        {
            Principal.mainForm.appParam.HTA.alarma = 140;
            Principal.mainForm.appParam.HTA.limitaSup = 120;
            Principal.mainForm.appParam.HTA.limitaInf = 60;
            Principal.mainForm.appParam.Puls.alarma = 85;
            Principal.mainForm.appParam.Puls.limitaInf = 60;
            Principal.mainForm.appParam.Puls.limitaSup = 80;
            Principal.mainForm.appParam.Greutate.alarma = 130;
            Principal.mainForm.appParam.Greutate.limitaInf = 45;
            Principal.mainForm.appParam.Greutate.limitaSup = 120;
            Principal.mainForm.appParam.FrecventaRespiratorie.alarma = 18;
            Principal.mainForm.appParam.FrecventaRespiratorie.limitaInf = 14;
            Principal.mainForm.appParam.FrecventaRespiratorie.limitaSup = 16;
            Principal.mainForm.appParam.Gaz.alarma = 1;
            Principal.mainForm.appParam.Gaz.limitaInf = 0;
            Principal.mainForm.appParam.Gaz.limitaSup = 1;
            Principal.mainForm.appParam.Umiditate.alarma = 1;
            Principal.mainForm.appParam.Umiditate.limitaInf = 0;
            Principal.mainForm.appParam.Umiditate.limitaSup = 1;
            Principal.mainForm.appParam.RFID.alarma = 1;
            Principal.mainForm.appParam.RFID.limitaInf = 0;
            Principal.mainForm.appParam.RFID.limitaSup = 1;
            Principal.mainForm.appParam.Tensiune.alarma = 0;
            Principal.mainForm.appParam.Tensiune.limitaInf = 0;
            Principal.mainForm.appParam.Tensiune.limitaSup = 0;
            Principal.mainForm.appParam.Glicemie.alarma = 110;
            Principal.mainForm.appParam.Glicemie.limitaInf = 60;
            Principal.mainForm.appParam.Glicemie.limitaSup = 100;
        }

        public void updateParametrii(ref Parametrii myParam)
        {
         //   myParam.parametriiCurenti.EKG = (short)myParam.RandomClass.Next(myParam.EKG.limitaInf, myParam.EKG.limitaSup);
         //   txtEKGdata.Text = myParam.parametriiCurenti.EKG.ToString();
        
            myParam.parametriiCurenti.HTA.Diastolic   = (ushort)myParam.RandomClass.Next(myParam.HTA.limitaInf, myParam.HTA.limitaSup);
            txtDiastolica .Text  = myParam.parametriiCurenti.HTA.Diastolic .ToString();

            myParam.parametriiCurenti.HTA.Sistolic = (ushort)myParam.RandomClass.Next(myParam.HTA.limitaInf, myParam.HTA.limitaSup);
            txtSistolica .Text  = myParam.parametriiCurenti.HTA.Sistolic .ToString();

            myParam.parametriiCurenti.puls = (ushort)myParam.RandomClass.Next(myParam.Puls.limitaInf, myParam.Puls.limitaSup);
            txtPulsdata .Text  = myParam.parametriiCurenti.puls.ToString();

            myParam.parametriiCurenti.greutate = (ushort)myParam.RandomClass.Next(myParam.Greutate.limitaInf, myParam.Greutate.limitaSup);
            txtGreutatedata .Text  = myParam.parametriiCurenti.greutate.ToString();

            myParam.parametriiCurenti.frecvResp = (ushort)myParam.RandomClass.Next(myParam.FrecventaRespiratorie.limitaInf, myParam.FrecventaRespiratorie.limitaSup);
            txtFrecventaRespiratoriedata.Text = myParam.parametriiCurenti.frecvResp.ToString();
          
            myParam.parametriiCurenti.glicemie = (ushort)myParam.RandomClass.Next(myParam.Glicemie .limitaInf, myParam.Glicemie .limitaSup);
            txtGlicemiedata.Text = myParam.parametriiCurenti.glicemie.ToString();

            if (myParam.RandomClass.Next(myParam.Gaz.limitaInf, myParam.Gaz.limitaSup) == 1)
            {
                myParam.parametriiCurenti.gaz = true;
                cbxGaz .SelectedValue ="adevarat";
            }
            else
            {
                myParam.parametriiCurenti.gaz = false;
                cbxUmiditate.SelectedValue  = "fals";
            }
            if (myParam.RandomClass.Next(myParam.Umiditate.limitaInf, myParam.Umiditate.limitaSup) == 1)
            {
                myParam.parametriiCurenti.umiditate = true;
                cbxUmiditate.SelectedValue = "adevarat";
            }
            else
            {
                myParam.parametriiCurenti.umiditate = false;
                cbxUmiditate.SelectedValue  = "fals";
            }
            if (myParam.RandomClass.Next(myParam.RFID.limitaInf, myParam.RFID.limitaSup) == 1)
            {
                myParam.parametriiCurenti.RFID = true;
                cbxRFID.SelectedValue  = "adevarat";
            }
            else
            {
                myParam.parametriiCurenti.RFID = false ;
                cbxRFID.SelectedValue = "fals";
            }

        }

        private void cbxConfigurare_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (cbxConfigurare.SelectedIndex)
            {
                case 0://"HTA":
                    cbxLimitaSup.Visible = false;
                    cbxLimitaInf.Visible = false;
                    cbxAlarma.Visible = false;
                    nupLimitasup.Visible = true;
                    nupLimitainf.Visible = true;
                    nupAlarma.Visible = true;

                    nupLimitainf.Value = Principal.mainForm.appParam.HTA.limitaInf;
                    if (nupLimitainf.Visible == true && nupLimitasup.Visible == true)
                    {
                        nupLimitasup.Value = Principal.mainForm.appParam.HTA.limitaSup;
                        nupAlarma.Value = Principal.mainForm.appParam.HTA.alarma;
                    }
                    break;
                case 1://"Puls":
                    cbxLimitaSup.Visible = false;
                    cbxLimitaInf.Visible = false;
                    cbxAlarma.Visible = false;
                    nupLimitasup.Visible = true;
                    nupLimitainf.Visible = true;
                    nupAlarma.Visible = true;

                    nupAlarma.Value = Principal.mainForm.appParam.Puls.alarma;
                    if (nupLimitainf.Visible == true && nupLimitasup.Visible == true)
                    {
                        nupLimitainf.Value = Principal.mainForm.appParam.Puls.limitaInf;
                        nupLimitasup.Value = Principal.mainForm.appParam.Puls.limitaSup;
                    }
                    break;

                case 2://"Greutate":
                    cbxLimitaSup.Visible = false;
                    cbxLimitaInf.Visible = false;
                    cbxAlarma.Visible = false;
                    nupLimitasup.Visible = true;
                    nupLimitainf.Visible = true;
                    nupAlarma.Visible = true;

                    nupAlarma.Value = Principal.mainForm.appParam.Greutate.alarma;
                    if (nupLimitainf.Visible == true && nupLimitasup.Visible == true)
                    {
                        nupLimitainf.Value = Principal.mainForm.appParam.Greutate.limitaInf;
                        nupLimitasup.Value = Principal.mainForm.appParam.Greutate.limitaSup;
                    }
                    break;
                case 3://"Glicemie":
                    cbxLimitaSup.Visible = false;
                    cbxLimitaInf.Visible = false;
                    cbxAlarma.Visible = false;
                    nupLimitasup.Visible = true;
                    nupLimitainf.Visible = true;
                    nupAlarma.Visible = true;

                    nupAlarma.Value = Principal.mainForm.appParam.Glicemie.alarma;
                    if (nupLimitainf.Visible == true && nupLimitasup.Visible == true)
                    {
                        nupLimitainf.Value = Principal.mainForm.appParam.Glicemie.limitaInf;
                        nupLimitasup.Value = Principal.mainForm.appParam.Glicemie.limitaSup;
                    }
                    break;
                case 4:// "FrecventaRespiratorie":
                    cbxLimitaSup.Visible = false;
                    cbxLimitaInf.Visible = false;
                    cbxAlarma.Visible = false;
                    nupLimitasup.Visible = true ;
                    nupLimitainf.Visible = true ;
                    nupAlarma.Visible = true ;

                    nupAlarma.Value = Principal.mainForm.appParam.FrecventaRespiratorie.alarma;
                    if (nupLimitainf.Visible == true && nupLimitasup.Visible == true)
                    {
                        nupLimitainf.Value = Principal.mainForm.appParam.FrecventaRespiratorie.limitaInf;
                        nupLimitasup.Value = Principal.mainForm.appParam.FrecventaRespiratorie.limitaSup;
                    }
                    break;
                case 5://"Gaz":
                    cbxLimitaSup.Visible = true ;
                    cbxLimitaInf.Visible = true ;
                    cbxAlarma.Visible = true ;
                    nupLimitasup.Visible = false;
                    nupLimitainf.Visible = false;
                    nupAlarma.Visible = false;

                    if (Principal.mainForm.appParam.Gaz.alarma == 1)
                        cbxAlarma.SelectedIndex = 0;
                    else
                        cbxAlarma.SelectedIndex = 1;
                    if (cbxLimitaInf.Visible == true && cbxLimitaSup.Visible == true)
                    {
                        if (Principal.mainForm.appParam.Gaz.limitaInf == 1)
                            cbxLimitaInf.SelectedIndex = 0;
                        else
                            cbxLimitaInf.SelectedIndex = 1;
                        if (Principal.mainForm.appParam.Gaz.limitaSup == 1)
                            cbxLimitaSup.SelectedIndex = 0;
                        else
                            cbxLimitaSup.SelectedIndex = 1;
                    }
                    break;
                case 6://"Umiditate":
                    cbxLimitaSup.Visible = true;
                    cbxLimitaInf.Visible = true;
                    cbxAlarma.Visible = true;
                    nupLimitasup.Visible = false;
                    nupLimitainf.Visible = false;
                    nupAlarma.Visible = false;

                    if (Principal.mainForm.appParam.Umiditate.alarma == 1)
                        cbxAlarma.SelectedIndex = 0;
                    else
                        cbxAlarma.SelectedIndex = 1;
                    if (cbxLimitaInf.Visible == true && cbxLimitaSup.Visible == true)
                    {
                        if (Principal.mainForm.appParam.Umiditate.limitaInf == 1)
                            cbxLimitaInf.SelectedIndex = 0;
                        else
                            cbxLimitaInf.SelectedIndex = 1;
                        if (Principal.mainForm.appParam.Umiditate.limitaSup == 1)
                            cbxLimitaSup.SelectedIndex = 0;
                        else
                            cbxLimitaSup.SelectedIndex = 1;
                    }
                    break;
                case 7://"RFID":
                    cbxLimitaSup.Visible = true;
                    cbxLimitaInf.Visible = true;
                    cbxAlarma.Visible = true;
                    nupLimitasup.Visible = false;
                    nupLimitainf.Visible = false;
                    nupAlarma.Visible = false;

                    if (Principal.mainForm.appParam.RFID.alarma == 1)
                        cbxAlarma.SelectedIndex = 0;
                    else
                        cbxAlarma.SelectedIndex = 1;
                    if (cbxLimitaInf.Visible == true && cbxLimitaSup.Visible == true)
                    {
                        if (Principal.mainForm.appParam.RFID.limitaInf == 1)
                            cbxLimitaInf.SelectedIndex = 0;
                        else
                            cbxLimitaInf.SelectedIndex = 1;
                        if (Principal.mainForm.appParam.RFID.limitaSup == 1)
                            cbxLimitaSup.SelectedIndex = 0;
                        else
                            cbxLimitaSup.SelectedIndex = 1;
                    }
                    break;
                case 8://"Tensiune":
                    cbxLimitaSup.Visible = true;
                    cbxLimitaInf.Visible = true;
                    cbxAlarma.Visible = true;
                    nupLimitasup.Visible = false;
                    nupLimitainf.Visible = false;
                    nupAlarma.Visible = false;
                    if (Principal.mainForm.appParam.Tensiune.alarma == 1)
                        cbxAlarma.SelectedIndex = 0;
                    else
                        cbxAlarma.SelectedIndex = 1;
                    if (cbxLimitaInf.Visible == true && cbxLimitaSup.Visible == true)
                    {
                        if (Principal.mainForm.appParam.Tensiune.limitaInf == 1)
                            cbxLimitaInf.SelectedIndex = 0;
                        else
                            cbxLimitaInf.SelectedIndex = 1;
                        if (Principal.mainForm.appParam.Tensiune.limitaSup == 1)
                            cbxLimitaSup.SelectedIndex = 0;
                        else
                            cbxLimitaSup.SelectedIndex = 1;
                    }
                    break;
                default:
                    MessageBox.Show("Trebuie sa selectati un senzor pentru configurare parametrii ", "Eroare de configurare");
                    break;
            }
        }
    }
}
